 /**
 * 逻辑、功能相关描述: <br>
 *
 * @author 付湘辉  <br>
 * 编写日期：2008-8-6  <br>
 */
package com.ce.pms.base.vo;

import com.ce.pms.common.model.SysrefcodeDO;
import com.ce.pms.exception.BusinessException;
import com.sitechasia.webx.core.model.IViewObject;

/**
 * 	名称: com.ce.pms.base.vo.SearchVO <br>
 *  搜索VO基类
 *
 * @author  付湘辉  <br>
 * Created on： 2008-8-6 <br>
 * @author <br>
 * update on： <br>
 * why: <br>
 */
public class SearchVO implements IViewObject {

	/**
	 * 默认的当前页码 值：1
	 */
	public static final Integer DEFAULT_PAGE_NO = SysrefcodeDO.CONSTANTS_ONE;

	/**
	 * 默认的页大小 值：15
	 */
	public static final Integer DEFAULT_PAGE_SIZE = 15;

	/**
	 * long：serialVersionUID
	 */
	private static final long serialVersionUID = -6101045774326333122L;

	/**
	 * 当前页码
	 */
	private Integer pageNo;

	/**
	 * 页大小
	 */
	private Integer pageSize;

	/**
	 * 排序字段
	 */
	private String sortStr;

	/**
	 * @param pageNo
	 * @param pageSize
	 * @param sortStr
	 */
	public SearchVO(String sortStr,Integer pageNo, Integer pageSize) {
		this.pageNo = pageNo;
		this.pageSize = pageSize;
		this.sortStr = sortStr;
	}

	/**
	 *
	 */
	public SearchVO() {

	}

	/**
	 * 功能描述:返回排序字符的关键字，即desc或asc<br>
	 * @return<br>
	 * Create author:罗军林<br>
	 * Create on:2008-11-6<br>
	 * Edit author:<br>
	 * Edit on:<br>
	 * Why:<br>
	 */
	public String getOrderKey(){
		if(null==sortStr)return "";

		String[] temp=sortStr.split(" ");
		return temp.length>1 ? temp[1] : "";
	}

	/**
	 * 功能描述:返回排序字符的字段名,即要对哪个字段进行排序<br>
	 * @return<br>
	 * Create author:罗军林<br>
	 * Create on:2008-11-6<br>
	 * Edit author:<br>
	 * Edit on:<br>
	 * Why:<br>
	 */
	public String getOrderValue(){
		if(null==sortStr)return null;

		String[] temp=sortStr.split(" ");
		return temp[0];
	}


	/**
	 * @return the pageNo
	 */
	public Integer getPageNo() {
		return pageNo;
	}

	/**
	 * @param pageNo the pageNo to set
	 */
	public void setPageNo(Integer pageNo) {
		this.pageNo = pageNo;
	}

	/**
	 * @return the pageSize
	 */
	public Integer getPageSize() {
		return pageSize;
	}

	/**
	 * @param pageSize the pageSize to set
	 */
	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}

	/**
	 * @return the sortStr
	 */
	public String getSortStr() {
		return sortStr;
	}

	/**
	 * @param sortStr the sortStr to set
	 */
	public void setSortStr(String sortStr) {
		this.sortStr = sortStr;
	}

	/**
	 * 功能描述: 检查当前页码和页大小规则 <br>
	 *
	 *
	 * Create author:付湘辉 <br>
	 * Create on:2008-8-6  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public void checkRule(){
		if (this.pageNo==null){
			this.pageNo=DEFAULT_PAGE_NO;
		}
		if (this.pageSize ==null){
			this.pageSize=DEFAULT_PAGE_SIZE;
		}

		if (this.pageNo < 1 || this.pageSize < 1) {
			throw new BusinessException("common:page_no_size_lessthan_one_exception",
					BusinessException.WARNING);
		}
	}
}
